package fun.ticsmyc.main;

import fun.ticsmyc.service.InformationService;

import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 用于可执行jar包。。。
 *
 * @author Ticsmyc
 * @package fun.ticsmyc.main
 * @date 2020-01-26 21:51
 */
public class Main {
    public static void main(String[] args) throws Exception {
//        Files.walkFileTree(Paths.get("t1"), new SimpleFileVisitor<Path>() {
//            @Override
//            public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes) throws IOException {
//                Files.deleteIfExists(path);
//                return FileVisitResult.CONTINUE;
//            }
//        });

        //deleteDirs(Paths.get("t1"));

        //每十分钟执行一次
        new Timer("testTimer").schedule(new TimerTask() {
            @Override
            public void run() {
                fffffuck();
            }
        }, 1000, 600000);
    }

    public static void fffffuck() {


        InformationService informationService = new InformationService();
        informationService.getNews();
    }

    public static void deleteDirs(Path path) throws Exception {
        System.out.println(path.toString());
        if (Files.list(path).count() > 0) {
            Files.list(path).forEach((o) -> {
                try {
                    deleteDirs(o);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        }
        Files.deleteIfExists(path);
    }
}
